package se137.hrbust.hlgshopping137.utils;

public class Result137<T> {
    private Integer code;
    private String msg;
    private Object data;

    public Result137() {
    }

    public Result137(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public Result137 setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public Result137 setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Object getData() {
        return data;
    }

    public Result137 setData(Object data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }

    public Result137 setCode(ResultEnum137 resultEnum) {
        this.code = resultEnum.code;
        return this;
    }
    public Result137 ok(Object data){
        Result137 ret=new Result137();
        ret.setCode(200);
        ret.setMsg("ok");
        ret.setData(data);
        return ret;
    }
    public Result137 fail(Object data){
        Result137 ret=new Result137();
        ret.setCode(500);
        ret.setMsg("fail");
        ret.setData(data);
        return ret;
    }
}
